#!/usr/bin/env python
#-*- coding: GB2312 -*-

import sys
from multiprocessing import Process

import importme
from models import model, page_parse

db_reader = model.reader
db_writer = model.writer


if __name__ == '__main__':
    total = db_reader.product.count()
    page_parse.record_price(db_reader, db_writer, 0, total)

    """
    process_num = 3
    offset = total / process_num
    remain = total % offset

    all_process = []

    for i in xrange(process_num):
        begin = i * offset
        if i == process_num - 1:
            offset += remain
        
        p = Process(target=page_parse.record_price, args=(db_reader, db_writer, begin, offset))
        all_process.append(p)
        p.start()

    for p in all_process:
        p.join()
    """
